<%@ page language="java" import="java.util.*" pageEncoding="utf-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<style>
.detailTable input[type="text"]{
	width: 210px;
}
</style>
<div class="easyui-layout" style="width:100%;height:100%;" fit="true">
    <div data-options="region:'center',title:'',split:true" style="height:100%;">
		<form id="userInfoForm" method="post" >
			<input type="hidden" id="providerId" name="providerId" data-options="required:true">        
			<input type="hidden" id="userName" name="userName"><!-- 用户名：chsName -->
			<input type="hidden" id="email" name="email"><!-- 电子邮箱： -->
			<input type="hidden" id="qq" name="qq"><!-- QQ： -->
			<input type="hidden" id="address" name="address"><!-- 地址：address -->
			<input type="hidden" id="mobilePhone" name="mobilePhone"><!-- 手机号码： -->
			<input type="hidden" id="telePhone" name="telePhone"><!-- 座机： -->
			<input type="hidden" id="postCode" name="postCode"><!-- 邮编： -->
			<input type="hidden" id="notes" name="notes"><!-- 备注： -->
			<input type="hidden" id="linkMan" name="linkMan"><!-- 联系人： -->
			<input type="hidden" id="extendCode" name="extendCode"><!-- 企业编码： -->
			<table class="detailTable"> 
    	 	<tr>
                <th>登录名:</th> 
                <td><input class="easyui-validatebox " id="loginName" name="loginName" data-options="required:true"></td>
            </tr>
            <tr>
                <th>密码:</th>
                <td><input class="easyui-validatebox " type="password" id="loginPwd" name="loginPwd" data-options="required:true"></td>
            </tr>
            <tr>
                <th>再次输入密码:</th>
                <td><input class="easyui-validatebox " type="password" id="loginPwd1" name="loginPwd1" data-options="required:true" validType="same['loginPwd']"></td>
            </tr>
            <tr>
                <th>用户类型:</th>
                <td>
                    <input type="radio" id="userType" name="userType" value="1" checked="checked">厂家
					<!-- <input type="radio" id="userType" name="userType" value="2" >药店
					<input type="radio" id="userType" name="userType" value="3" >业务员   -->
               </td>
			<tr>
			   
				<td align="center" colspan="2" > 
					<input type="button" onclick="submitForm()" class="button" value="提交" >
				<!-- 	<input type="button" onclick="pms.resetForm('userInfoForm')" class="button" value="重置" >    --> 
				</td>
			</tr>
		</table>
		</form>
    </div>
</div>  
<script>
$(function(){
	var providerId="<%=request.getParameter("code")%>";
	var param = {"providerId":providerId};
		$.pmsAjax({
		url:'<c:url value="/emcprovider/showEmCProviderDetail.do"/>',
		data:param,
		success:function(data){
			var emCProvider = data.data.emCProvider;	
			//console.log(emCProvider);
			if(data.code=="200"){
				demoCProviderDetail(emCProvider);
			}else{
				alertError(data.result);
			}	
		}
	});
})
//返回数据load到from
function demoCProviderDetail(emCProvider){
	$('#userInfoForm').form('load',{
		providerId:emCProvider.providerId,
		userName:emCProvider.chsName,
		address:emCProvider.address,
		mobilePhone:emCProvider.mobile,
		telePhone:emCProvider.phone,
		postCode:emCProvider.zip,
		notes:emCProvider.notes,
		linkMan:emCProvider.consigner,
		extendCode:emCProvider.providerCode
	});
}
function submitForm(){
	$('#userInfoForm').form('submit', {
	    url:"/admin/user/addProviderUser.do",  
	    onSubmit: function(param){
	    	if(!$("#userInfoForm").form('validate')){
	    		return false;
	    	}
	    	//alert(url);
	    	//时间对比
	    }, 
	    success:function(data){
		    var ret = eval("("+data+")");
		    console.log(ret);
		   // alert(ret.code);
	     	if(ret.code=='200'){
	     		alertShow("新增成功");
	     		providersTable.refresh();
	     		$("#w_adduser").dialog('close');
		    }else{
		    	alertError(ret.result);
			}
	    }
	});
}


</script>
